#include "LuaLink_SceneNode.h"

LuaLink_SceneNode::LuaLink_SceneNode(const char* name) {
	mNode = LuaLink_SceneManager::INSTANCE->mSceneManager->getRootSceneNode()->createChildSceneNode(name);
}

LuaLink_SceneNode::LuaLink_SceneNode(LuaLink_SceneNode* parent, const char* name) {
	mParent = parent;
	mNode = parent->mNode->createChildSceneNode(name);
}

LuaLink_SceneNode::~LuaLink_SceneNode(void) {

}

void LuaLink_SceneNode::lua_attach(LuaLink_Entity* entity) {
	mNode->attachObject(entity->mEntity);
}

void LuaLink_SceneNode::lua_detach(const char* name) {
	mNode->detachObject(name);
}

LuaLink_SceneNode* LuaLink_SceneNode::lua_createChild(const char* name) {
	return new LuaLink_SceneNode(this, name);
}

void LuaLink_SceneNode::lua_position(Ogre::Vector3* vec) {
	mNode->setPosition(*vec);
}

void LuaLink_SceneNode::lua_translate(Ogre::Vector3* vec) {
	mNode->translate(*vec);
}

void LuaLink_SceneNode::lua_roll(Ogre::Real angle) {
	mNode->roll(Ogre::Radian(angle));
}

void LuaLink_SceneNode::lua_pitch(Ogre::Real angle) {
	mNode->pitch(Ogre::Radian(angle));
}

void LuaLink_SceneNode::lua_yaw(Ogre::Real angle) {
	mNode->yaw(Ogre::Radian(angle));
}

void LuaLink_SceneNode::lua_scale(Ogre::Vector3* vec) {
	mNode->scale(*vec);
}

Ogre::Vector3* LuaLink_SceneNode::lua_getPosition() {
	return new Ogre::Vector3(mNode->getPosition().x, mNode->getPosition().y, mNode->getPosition().z);
}

void LuaLink_SceneNode::lua_rotate(Ogre::Real x, Ogre::Real y, Ogre::Real z) {
	mNode->pitch(Ogre::Radian(x));
	mNode->yaw(Ogre::Radian(y));
	mNode->roll(Ogre::Radian(z));
}
